/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package control;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import model.beans.Paciente;

/**
 *
 * @author kelyane
 */
public class PacienteTableModel extends AbstractTableModel{
    
  //  String[] column = {"Nome Paciente". "RG", "CPF", "Telefone"};
    
    ArrayList<Paciente> dado = new ArrayList<>();

    @Override
    public int getRowCount() {
        return dado.size();  
    }

    @Override
    public int getColumnCount() {
        return 4;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        
        Paciente paciente = getRow(rowIndex);
        
        if(columnIndex == 0){
            return paciente.getNome();
        }else if(columnIndex == 1){
            return paciente.getRg().getRG();
        }else if(columnIndex == 2){
            return paciente.getCpf().getCPF();
        }else if(columnIndex == 3){
            return paciente.getCelular();
        }else{
            return null;
        }
        
    }
    
    public void addRow(Paciente paciente){
        dado.add(paciente);
    }
    
    public Paciente getRow(int rowIndex){
        return dado.get(rowIndex);
    }
    
    @Override
    public String getColumnName(int columnIndex) {
        if(columnIndex == 0){
            return "Nome Paciente";
        }else if(columnIndex == 1){
            return "RG";
        }else if(columnIndex == 2){
            return "CPF";
        }else if(columnIndex == 3){
            return "Telefone";
        }else{
            return null;
        }
    }
    
    
}
